﻿using Permissions.RoleApp;
using Permissions.RoleApp.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Permissions.Web.Controllers
{
    public class RoleController : Controller
    {
        private readonly IRoleAppService _roleRepository;

        public RoleController(IRoleAppService roleRepository)
        {
            _roleRepository = roleRepository;
        }

        // GET: Role
        public ActionResult Index()
        {
            var roles = _roleRepository.GetRoles();

            return View(roles);
        }

        public ActionResult Create(CreateRoleInput Role)
        {
            if (Role.Name==null)
            {
                return View();
            }
            else
            {
                _roleRepository.CreateRole(Role);

                return RedirectToAction("Index");
            }
        }
    }
}